package leetcode;

import java.util.Arrays;

/**
 * 最长递增子序列
 */
public class Solution60 {
    public int lengthOfLIS(int[] nums) {
        if(nums.length <= 1){
            return nums.length;
        }
        int[] dp = new int[nums.length];
        int res = 1;
        Arrays.fill(dp,1);
        //遍历数组
        for(int i = 1;i < nums.length;i++){
            for(int j = 0;j < i;j++){
                if(nums[i] > nums[j]){
                    dp[i] = Math.max(dp[i],dp[j] + 1);
                }
            }
            res = Math.max(res,dp[i]);
        }
        return res;
    }
}
